from lib import log

from objects import Living

class Player(Living.Living):
	def __init__(self, playerId, connection, location, world):
		super(Player, self).__init__(playerId, "Player {0}".format(playerId), location, world)
		self._playerId = playerId
		self._connection = connection
		
	@property
	def playerId(self): return self._playerId
	@property
	def connection(self): return self._connection
	
	@property
	def isPlayer(self): return True
	
	def comeAlive(self):
		self.notify("{0} magically appears.".format(self.name))
		self.message(self, "Welcome back, {0}.".format(self.name))
	
	def die(self):
		self.notify("{0} dies.".format(self.name))
		self.message(self, "You die.")
	
	def heartbeat(self):
		super(Player, self).heartbeat()
	
	def message(self, s):
		self.connection.sendQueue.put_nowait({'type': 'PRINT', 'message': s})